﻿var SVGNS = "http://www.w3.org/2000/svg";
var XLINKNS = "http://www.w3.org/1999/xlink";

function testAudio(name) {
    game.content.playAudio(name);
}

function randomNumber(max) {
    return Math.floor(Math.random() * max);
}

function findArrayElement(arrayElementToFind, arrayToSearch) {
    for (var i = 0; i < arrayToSearch.length; i++)
        if (arrayElementToFind == arrayToSearch[i].name) {
            
            return arrayToSearch[i];
            break;
        }    
    }

function addElementToDocument(elementName, parent, ns) {
    var element;
    if (parent == null)
        parent = document.body;

    if (ns == null) {
        element = document.createElement(elementName);
    }
    else {
        element = document.createElementNS(ns,elementName);
        
    }
    parent.appendChild(element);
    return element; 
}


function centerElement(element) {
    element.style.width = dialogMessage.width + "px";
    element.style.height = dialogMessage.height + "px";
    element.style.top = game.board.height / 2 - (parseInt(element.style.height) / 2) + "px";
    element.style.left = game.board.width / 2 - (parseInt(element.style.width) / 2) + "px";
}


function removeChildren(parent) {
    while (parent.firstChild != null)
        parent.removeChild(parent.firstChild);
}